{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% load i18n %}

{# Omit assigned IP addresses from object representation #}
{% block title %}{{ object.get_protocol_display }}: {{ object.group_id }}{% endblock %}

{% block breadcrumbs %}
  {{ block.super }}
  <li class="breadcrumb-item"><a href="{% url 'ipam:fhrpgroup_list' %}?protocol={{ object.protocol }}">{{ object.get_protocol_display }}</a></li>
{% endblock breadcrumbs %}

{% block content %}
  <div class="row">
    <div class="col col-12 col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "FHRP Group" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Protocol" %}</th>
            <td>{{ object.get_protocol_display }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Group ID" %}</th>
            <td>{{ object.group_id }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Name" %}</th>
            <td>{{ object.name|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Description" %}</th>
            <td>{{ object.description|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Members" %}</th>
            <td>{{ member_count }}</td>
          </tr>
        </table>
      </div>
      {% include 'inc/panels/tags.html' %}
      {% include 'inc/panels/comments.html' %}
      {% plugin_left_page object %}
    </div>
    <div class="col col-12 col-md-6">
      <div class="card">
        <h2 class="card-header">{% trans "Authentication" %}</h2>
        <table class="table table-hover attr-table">
          <tr>
            <th scope="row">{% trans "Authentication Type" %}</th>
            <td>{{ object.get_auth_type_display|placeholder }}</td>
          </tr>
          <tr>
            <th scope="row">{% trans "Authentication Key" %}</th>
            <td>{{ object.auth_key|placeholder }}</td>
          </tr>
        </table>
      </div>
      {% include 'inc/panels/related_objects.html' %}
      {% include 'inc/panels/custom_fields.html' %}
      {% plugin_right_page object %}
    </div>
  </div>
  <div class="row">
    <div class="col col-md-12">
      <div class="card">
        <h2 class="card-header">
          {% trans "Virtual IP Addresses" %}
          {% if perms.ipam.add_ipaddress %}
            <div class="card-actions">
              <a href="{% url 'ipam:ipaddress_add' %}?fhrpgroup={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-ghost-primary btn-sm">
                <i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add IP Address" %}
              </a>
            </div>
          {% endif %}
        </h2>
        {% htmx_table 'ipam:ipaddress_list' fhrpgroup_id=object.pk %}
      </div>
      {% include 'inc/panel_table.html' with table=members_table heading='Members' %}
      {% plugin_full_width_page object %}
    </div>
  </div>
{% endblock %}
